$(document).ready(function(){
    $('#tabs').tabs();
    $('#submit').button().click(function(){
            $('form').submit();});
    $('#colaborador').autocomplete({
        source: function(request, response) {
            $.ajax({
                url: "/colaborador/index",
                type: "POST",
                datatype: "json",
                data: { q: request.term },
                success: function(data) {
                    response($.map(data.colaboradores, function(item) {
                        return {
                            label: item.nome,
                            value: item.codusu
                        }
                    }))
                }
            })
        },
        focus: function(event,ui){$('#ac_colaborador').val(ui.item.label); return false;},
        open: function(event,ui) {$('#colaborador_id').val('');},
        select: function(event,ui){ $('#colaborador_id').val(ui.item.value); $('#colaborador').val(ui.item.label); return false;},
        minLength: 3,
        delay: 300
    });

})